﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._21_观察者模式
{
    /// <summary>
    /// 具体观察者 - 库存系统
    /// </summary>
    public class InventorySystem: IOrderObserver
    {
        public void Update(TOrderModel order)
        {
            if(order.Status == OrderStatus.Paid)
            {
                Console.WriteLine($"[库存系统] 订单 {order.OrderId} 已付款，扣除库存:");
                foreach (var productId in order.ProductIds)
                {
                    Console.WriteLine($"- 产品 {productId} 库存-1");
                }
                Console.WriteLine();
            }
        }



    }
}
